let request = require('../../utils/request.js')

// pages/business/business.js
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageHeight: app.globalData.pageHeight,
    paddingTop: app.globalData.paddingTop,
    goodsShow: true,
    shopId: null,
    ticketList: [],
    goodsList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let shopId = wx.getStorageSync('shopId')
    console.log('店铺id：', shopId)
    this.setData({
      shopId: shopId
    })
    this.getShopTicketPage(shopId)
    this.getShopGoodsPage(shopId)
  },
  bindTisp() {
    wx.showToast({
      title: '正在测试，尽请期待',
      icon: 'none'
    })
  },
  tabCut(e) {
    let val = e.currentTarget.dataset.s
    console.log(val)
    this.setData({
      goodsShow: val
    })
  },
  /**
   * 分页查询优惠券
   */
  getShopTicketPage(id) {
    request.http('/shop/shop-ticket/page', 'GET', {shopId: id})
      .then(res => {
        let data = res.data
        if(data.code == 200) {
          this.setData({
            ticketList: data.data.records
          })
        }
      })
  },
  /**
   * 分页查询商品
   */
  getShopGoodsPage(id) {
    request.http('/shop/shop-goods/page', 'GET', {shopId: id})
      .then(res => {
        let data = res.data
        if(data.code == 200) {
          this.setData({
            goodsList: data.data.records
          })
        }
      })
  }





})